﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using SmallShop.Frame;

namespace SmallShop.BaseWeb
{
    /// <summary>
    /// 权限认证
    /// </summary>
    public class SmallAuthorizeAttribute: AuthorizeAttribute
    {
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            if (!filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
            {
                base.HandleUnauthorizedRequest(filterContext);
            }
            else
            {
                filterContext.Result = new JsonetResult { Data = new ResultModel { Code =  ResultModel.NotLogin} };
            }
        }
    }
}
